package org.asociacion.backend.persistence;

import java.io.Serializable;
import java.util.List;

public interface GenericDao<T, PK extends Serializable> {
	
	/**
	 * Create an object, this replaces: insert into
	 * @param obj object to insert.
	 */
	void create(T obj);
	
	/**
	 * Retrieve a complete object from an id, this replaces: select * from table where id=id
	 * @param id The primary key of the object.
	 * @return It is the found object by the id. If the id doesn't exist, the object is null.
	 */
	T read(PK id);
	
	/**
	 * Update every value of an object, this replaces: update from table set ...
	 * @param obj This object contains the new values.
	 */
	void update(T obj);
	
	/**
	 * Erase an object, this replaces: delete from table where id = id 
	 * @param obj Object to erase
	 */
	void delete(T obj);
	
	/**
	 * Retrieve every value of a table. 
	 * @return	A list of object
	 */
	List<T> list();
	
	/**
	 * Retrieve the table values from an explicit beginning and a limit.
	 * @param start It is beginning value og the table
	 * @param max It is the row limit to retrieve.
	 * @return A list of object
	 */
	List<T> list(int start, int max);
	
	/**
	 * Retrieve the total number of rows of the table
	 * @return The number with the count.
	 */
	Integer getCount();

}
